package ch15;

import java.util.Scanner;

public class CompanyTest {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        Company company = new Company("天宇", "周口店", "1531246984", "全村");//String companyName, String address, String phone, String range
        while (true) {
            System.out.println("1.入职新员工");
            System.out.println("2.开除员工");
            System.out.println("3.输出员工信息");
            System.out.println("4.输出公司信息");
            System.out.println("5.显示公司薪水最高的员工信息");
            System.out.println("6.退出");
            System.out.print("请输入选择（0-6）：");
            int chooice = 0;
            while (true) {
                chooice = scan.nextInt();
                if (chooice < 0 || chooice > 6) {
                    System.out.println("输入错误，请重新输入！");
                } else {
                    break;
                }
            }
            switch (chooice) {
                case 1://String name, int age, String gender, String post, double salary, String no
                    System.out.println("************入职新员工*************");
                    System.out.println("请输入入职员工的姓名：");
                    String name = scan.next();
                    System.out.println("请输入入职员工的年龄：");
                    int age = scan.nextInt();
                    System.out.println("请输入入职员工的性别：");
                    String gender = scan.next();
                    System.out.println("请输入职员工入职的职位：");
                    String post = scan.next();
                    System.out.println("请输入入职员工的期望薪资：");
                    double salary = scan.nextDouble();
                    System.out.println("请输入入职员工的工号：");
                    String no = scan.next();
                    Staff staff = new Staff(name, age, gender, post, salary, no);
                    if (company.setListstaff(staff)) {
                        System.out.println("招聘成功");
                    } else {
                        System.out.println("招聘失败");
                    }
                    break;
                case 2:
                    System.out.println("************开除员工*************");
                    System.out.println("请输入想要删除的员工的工号：");
                    String deleteNo=scan.next();
                    if(company.delete(deleteNo)){
                        System.out.println("删除成功");
                    }else {
                        System.out.println("删除失败，没有改工号");
                    }
                    break;
                case 3:
                    System.out.println("************输出员工信息*************");
                    company.showStaff();
                    break;
                case 4:
                    System.out.println("************输出公司信息*************");
                    company.showCompany();
                    break;
                case 5:
                    System.out.println("************显示公司薪水最高的员工信息*************");
                    company.maxSalary();
                    break;
                case 6:
                    System.out.print("是否退出（Y/N）:");
                    while (true) {
                        String isExit = scan.next();
                        if (isExit.equals("Y")) {
                            return;
                        } else {
                            break;
                        }
                    }
                    break;
            }

        }
    }
}
